﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

#endregion

using Weazel.Badger.Vhdl.Types;

namespace Weazel.Badger.Vhdl.Operators.Binary
{
  public class Add : BinaryFunction
  {
    private static BinaryTypeMap[] signedTypeMaps = new BinaryTypeMap[]
      {       
        /*
        new BinaryTypeMap(Types.Signed, Types.Signed, Types.Signed),
        new BinaryTypeMap(Types.Unsigned, Types.Signed, Types.Signed),
        new BinaryTypeMap(Types.Signed, Types.Unsigned, Types.Signed),
        new BinaryTypeMap(Types.Signed, Types.Integer, Types.Signed),
        new BinaryTypeMap(Types.Integer, Types.Signed, Types.Signed),  
        */
        new BinaryTypeMap(Types.Types.Signed, Types.Types.Signed, Types.Types.StdLogicVector),
        new BinaryTypeMap(Types.Types.Unsigned, Types.Types.Signed, Types.Types.StdLogicVector),
        new BinaryTypeMap(Types.Types.Signed, Types.Types.Unsigned, Types.Types.StdLogicVector),
        /*
        new BinaryTypeMap(Types.Signed, Types.Integer, Types.StdLogicVector),
        new BinaryTypeMap(Types.Integer, Types.Signed, Types.StdLogicVector)
      */
      };

    private static BinaryTypeMap[] unsignedTypeMaps = new BinaryTypeMap[]
      {
        new BinaryTypeMap(Types.Types.Unsigned, Types.Types.Unsigned, Types.Types.StdLogicVector),
        new BinaryTypeMap(Types.Types.Unsigned, Types.Types.Signed, Types.Types.StdLogicVector),
        new BinaryTypeMap(Types.Types.Signed, Types.Types.Unsigned, Types.Types.StdLogicVector),

        /*
        new BinaryTypeMap(Types.Unsigned, Types.Unsigned, Types.Unsigned),      
        new BinaryTypeMap(Types.Unsigned, Types.Integer, Types.Unsigned),
        new BinaryTypeMap(Types.Integer, Types.Unsigned, Types.Unsigned)
      */
      };

    public override BinaryTypeMap[] SignedTypeMaps
    {
      get 
      {
        return signedTypeMaps;
      }
    }

    public override BinaryTypeMap[] UnsignedTypeMaps
    {
      get
      {
        return unsignedTypeMaps;
      }
    }

    public Add()
    {
    }

    public override string ToString(string left, string right, int width)
    {
      return string.Format("{0} + {1}", left, right);
    }

  }
}
